<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ESP32 工具测试页面</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body class="bg-gray-900 text-white min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <header class="text-center mb-10">
            <h1 class="text-3xl font-bold text-indigo-400 mb-2">
                <i class="fas fa-microchip mr-2"></i>ESP32 开发工具测试
            </h1>
            <p class="text-gray-400">用于验证UI组件和资源加载</p>
        </header>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
            <!-- 测试卡片1 -->
            <div class="bg-gray-800 rounded-lg shadow-lg p-6 border border-gray-700">
                <div class="flex items-center mb-4">
                    <i class="fas fa-check-circle text-green-500 text-xl mr-3"></i>
                    <h2 class="text-xl font-semibold">资源加载测试</h2>
                </div>
                <div class="space-y-3">
                    <div class="flex items-center">
                        <i class="fas fa-circle text-green-500 text-xs mr-2"></i>
                        <span>CDN资源加载</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-circle text-green-500 text-xs mr-2"></i>
                        <span>本地CSS加载</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-circle text-green-500 text-xs mr-2"></i>
                        <span>图标字体加载</span>
                    </div>
                </div>
            </div>

            <!-- 测试卡片2 -->
            <div class="bg-gray-800 rounded-lg shadow-lg p-6 border border-gray-700">
                <div class="flex items-center mb-4">
                    <i class="fas fa-palette text-blue-500 text-xl mr-3"></i>
                    <h2 class="text-xl font-semibold">UI组件测试</h2>
                </div>
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-300 mb-1">选择框</label>
                        <select class="w-full bg-gray-700 border border-gray-600 rounded-lg py-2 px-3 text-white">
                            <option>选项1</option>
                            <option>选项2</option>
                        </select>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-300 mb-1">输入框</label>
                        <input type="text" class="w-full bg-gray-700 border border-gray-600 rounded-lg py-2 px-3 text-white" placeholder="输入内容">
                    </div>
                    <div class="flex space-x-2">
                        <button class="flex-1 bg-indigo-600 hover:bg-indigo-700 text-white py-2 px-4 rounded-lg transition">
                            按钮1
                        </button>
                        <button class="flex-1 bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-lg transition">
                            按钮2
                        </button>
                    </div>
                </div>
            </div>

            <!-- 测试卡片3 -->
            <div class="bg-gray-800 rounded-lg shadow-lg p-6 border border-gray-700 md:col-span-2">
                <div class="flex items-center mb-4">
                    <i class="fas fa-code text-yellow-500 text-xl mr-3"></i>
                    <h2 class="text-xl font-semibold">模块加载测试</h2>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                    <div class="bg-gray-700 rounded p-4">
                        <h3 class="font-medium mb-2">状态管理</h3>
                        <div id="state-test" class="text-sm text-gray-400">未加载</div>
                    </div>
                    <div class="bg-gray-700 rounded p-4">
                        <h3 class="font-medium mb-2">UI管理</h3>
                        <div id="ui-test" class="text-sm text-gray-400">未加载</div>
                    </div>
                    <div class="bg-gray-700 rounded p-4">
                        <h3 class="font-medium mb-2">代码生成</h3>
                        <div id="code-test" class="text-sm text-gray-400">未加载</div>
                    </div>
                </div>
            </div>
        </div>

        <div class="mt-8 text-center">
            <button id="run-test" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-6 rounded-lg transition">
                <i class="fas fa-play mr-2"></i>运行测试
            </button>
            <div id="test-result" class="mt-4 text-sm text-gray-400 hidden">
                测试结果将在这里显示...
            </div>
        </div>
    </div>

    <script type="module">
        document.getElementById('run-test').addEventListener('click', async function() {
            const resultDiv = document.getElementById('test-result');
            resultDiv.classList.remove('hidden');
            resultDiv.textContent = '正在测试模块加载...';
            
            try {
                // 测试模块导入
                const stateModule = await import('./utils/state.js');
                document.getElementById('state-test').innerHTML = '<span class="text-green-500">✓ 已加载</span>';
                
                const uiModule = await import('./utils/ui-manager.js');
                document.getElementById('ui-test').innerHTML = '<span class="text-green-500">✓ 已加载</span>';
                
                const codeModule = await import('./utils/code-generator.js');
                document.getElementById('code-test').innerHTML = '<span class="text-green-500">✓ 已加载</span>';
                
                resultDiv.innerHTML = '<span class="text-green-500">✓ 所有模块加载成功！</span>';
            } catch (error) {
                resultDiv.innerHTML = `<span class="text-red-500">✗ 加载失败: ${error.message}</span>`;
                console.error('模块加载错误:', error);
            }
        });
    </script>
</body>
</html>